#include<iostream>
#include<string>
using namespace std;

struct free_throw
{
	string name;
	int made;
	int attempts;
	double percent;
};

void display(const free_throw& ft);
void set_pc(free_throw& ft);
free_throw& accumulate(free_throw& target, const free_throw& source);

int main()
{
	free_throw one = {"zhangsan",13,14};
	free_throw two = {"lisi",11,45};
	free_throw three = {"wangwu",14,19};
	free_throw team = {"team",0,0};
	
	set_pc(one);
	display(one);
	display(accumulate(team, one));
	accumulate(accumulate(team, two), three);
	display(team);
	return 0;
}

void display(const free_throw& ft)
{
	cout << "name:" << ft.name << endl;
	cout << "made:" << ft.made << endl;
	cout << "attempts:" << ft.attempts << endl;
	cout << "percent:" << ft.percent << endl;
}

void set_pc(free_throw& ft)
{
	if (ft.attempts)
		ft.percent = 100.0 * ft.made / ft.attempts;
	else
		ft.percent = 0;
}

free_throw& accumulate(free_throw& target, const free_throw& source)
{
	target.made += source.made;
	target.attempts += source.attempts;
	set_pc(target);
	return target;
}
